<?php
/*
 * Created by generator
 *
 */

class ListSituations extends Controller {

	/**
	 * Constructeur
	 */
	function ListSituations(){
		parent::Controller();
		$this->load->model('Situation_model');
		$this->load->library('session');
		$this->load->helper('url');
	}

	/**
	 * Affichage des Situations
	 */
	public function index(){
		$data['situations'] = Situation_model::getAllSituations($this->db);
		$this->load->view('listsituations_view', $data);
	}

	/**
	 * Ajout d'un Situation
	 */
	public function add(){

		// Insertion en base
		$model = new Situation_model();
		$model->sitidsit = $this->input->post('sitidsit'); 
		$model->sitlbnom = $this->input->post('sitlbnom'); 
		$model->save($this->db);

		$this->session->set_flashdata('message', 'Nouveau Situation ajoute');
		
		// Recharge la page avec les nouvelles infos
		redirect('listsituations/index'); 
	}

	/**
	 * Suppression d'un Situation
	 * @param $sitidsit identifiant a supprimer
	 */
	function delete($sitidsit){
		Situation_model::delete($this->db, $sitidsit);

		$this->session->set_flashdata('message', 'Situation supprime');

		redirect('listsituations/index'); 
	}

}
?>
